namespace('is.region', new function(){
    var _cache = {};

    this.register = function(name, titl, main, lout, lobj) {
        lout = (typeof(lout) != 'undefined') ? lout : null;
        lobj = (typeof(lobj) != 'undefined') ? lobj : name;
        _cache[name] = [titl, main, lout, lobj];
    }

    this.get = function(name, part) {
        part = (typeof(part) != 'undefined') ? part : 1;
        return _cache[name][part];
    }

    this.conv = function(name) {
        return name.replace(/\s+/g, '_').toLowerCase()
    }

    this.view = function(name) {
        return is.region.get(name).attr('view');
    }

    this.load = function(name, title, path) {
        is.region.get(name).attr('view', this.conv(title));
        is.region.get(name, 0).html(title)
        is.region.get(name).load(path, function(){
            is.reapply_all(is.region.get(name));
        });
    }

    this.init = function() {
        is.region.register('east', $('#east .bar div'), $('#east .ui-layout-center'), is.layout.main);
        is.region.register('west', $('#west .bar div'), $('#west .ui-layout-center'), is.layout.main);
        is.region.register('main', $('#navi .ui-layout-center'), $('#cont'), is.layout.body, 'south');
    }

    is.register('init', this);
});
